mui.init({
//	preloadPages:[{
//		id:'invest_record_page',
//		url:'../invest_record/invest_record.html'
//	}]
});
mui.plusReady(function() {
	var self = plus.webview.currentWebview();
	var formId = self.formId;
	var sessionId =	plus.storage.getItem(KeyCfg.JSESSIONID);
	/*---- 初始化数据 ---*/
	(function initData(){
		var url = UrlConfig.minvest_buyDetail;
		var formDatas = {loanid:formId,sessionId:sessionId};
		 MuiEventMgr.ajax(url,{pars:formDatas,
		  	sfn : function(data){
		  		console.log(data);
	        		renderData(data);
		  	}
		 });
	})();
	
	/**
	 * 将数据渲染到页面 
	 * @param {Object} data
	 */
	function renderData(data){
		var success = data.success;
		if(!success) return;
		//新增投资记录
		var count = data.count;
		var loanRecords = data.loanrecord;
		var htmlArr = [];
		for(var i=0,len=loanRecords.length; i<len; i++){
	    	var loanRecord = loanRecords[i];
	    	htmlArr[i] = getJbHtml(loanRecord);
    	}
		var htmlStr = htmlArr.join(" ");
    	$("#item_loanRecords").html(htmlStr);
	}
	
    function getJbHtml(loanRecord){
		var username = loanRecord.username;
		var tenderMoney = loanRecord.tenderMoney;
		var tenderTime = loanRecord.tenderTime;
    		var htmlArr = [
			
			'	<div class="app_buyrecord_tab">',
			'		<div class="word" style="width: 25%;text-align: left;padding-left:25px">'+username+'</div>',
			'		<div class="word" style="width: 35%;text-align: right;padding-right:25px">￥'+tenderMoney+'</div>',
			'		<div class="word" style="width: 40%;">'+tenderTime+'</div>',
			'	</div>'
			
			];
		return htmlArr.join(" ");
    }	
	
});
